//
//  BaseTableViewController.swift
//  TYHWeibo
//
//  Created by IOS on 15/7/28.
//  Copyright © 2015年 IOS. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {

    
        //设置登陆标记
        var userLogin = UserAccount.userLogin
    
//        var userLogin = false
        override func loadView(){
        //根据用户是否登陆判断是否替换根视图
            userLogin ? super.loadView() : setupVisitorView()
        
        }
    
    var visitorView: VisitorLoginView?
    
    ///设置访客视图
    private func setupVisitorView () {
        
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
        
        //设置状态栏
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
//        view.backgroundColor = UIColor.orangeColor()
        
    }
    
    func visitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
    }
 
}
